package com.ling.module1sbbyyds.controller.video;

import com.ling.sbbyyds.entity.video.VideoLike;
import com.ling.sbbyyds.interaction.param.VideoPo;
import com.ling.module1sbbyyds.service.video.VideoService;
import com.ling.sbbyyds.interaction.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("api/video/")
public class VideoController {

    @Autowired
    private VideoService videoService;

    /**
     * 获取视频列表
     *
     * @return
     */
    @GetMapping("getVideoList")
    public ResultVo getVideoList(Integer page, Integer limit){
        return videoService.getVideoList(page, limit);
    }

    /**
     * 点赞视频
     *
     * @param videoLike 内容
     * @param type      true：点赞  false：取消点赞
     * @return
     */
    @PostMapping("isLogin/likeVideo/{type}")
    public ResultVo likeVideo(VideoLike videoLike, @PathVariable Boolean type) {
        return videoService.likeVideo(videoLike, type);
    }

    /**
     * 发布视频
     * form-data请求，，携带图片文件
     *
     * @param videoPo   视频信息参数
     * @param file     视频文件
     * @return 成功反馈
     */
    @PostMapping("isLogin/releaseVideo")
    public ResultVo releaseVideo(@Validated VideoPo videoPo, @RequestParam(value = "file")MultipartFile file) throws Exception {
        return videoService.releaseVideo(videoPo, file);
    }

}
